*USING PSLM-HIES 2018-19 FARMS DATA
use "D:\Agriculture land inequality\farm size and prductivity\HIIES_data\HIES 2018-19\FINAL AMENDED\new data\final data", clear


foreach var in s10c1121  s10c1122  s10c1123  s10c1124  s10c1125  s10c1126  s10c1127  s10c1128  s10c1129  s10c1130 {
egen num_`var' = count(`var') if `var' !=. ,by (hhcode)
}

//egen num_crop=rsum(num_s10c1121 num_s10c1122 num_s10c1123 num_s10c1124 num_s10c1125 num_s10c1126 num_s10c1127 num_s10c1128 num_s10c1129 num_s10c1130)
//egen mean_num_crops= mean (num_crop),by(farm_size_dummy)


gen karif_crop1=1 if  num_s10c1122 !=. | num_s10c1123 !=. | num_s10c1124 !=. | num_s10c1125 !=.  | num_s10c1129     
gen rabi_crop1=1 if num_s10c1121 !=. | num_s10c1126 !=.    
egen rabi_karif1=rsum(karif_crop1 rabi_crop1)

gen farmsizesl =0
replace farmsizesl=1 if land_culti_total> 2.5 & land_culti_total !=.


//gen linput_costpa_total =ln(input_costpa_total)

//egen labor_cost_total_comb_own= rsum(family_labor_cost  owncul_labor_cost_comb sharecrop_labor_cost_comb contcul_labor_cost_comb otheroccup_labor_cost_comb)
//gen labor_costpa_total_comb_own= labor_cost_total_comb_own/land_culti_total
//gen llabor_costpa_total_comb_own=ln(labor_costpa_total_comb_own+1)


egen strata=group(province region)
svyset ps [pw=weights], strata(stra)
svyset ps [pw=weights], singleunit( scaled) strata(stra) 

// various controls
global xlist0    c.lfamily_labor_cost_share c.ldist_waterb c.ltransport_ratio1 i.land_irig_bi  i.landown_yn c.edu_level  c.family_size     
global xlistsq   c.lfamily_labor_cost_share c.ldist_waterb c.ltransport_ratio1 i.land_irig_bi  i.landown_yn c.edu_level  c.family_size c.lDEM_mean c.lrootwater_mean c.lROUGH_mean i.soil_qauality     
global xlist     c.lfamily_labor_cost_share c.ldist_waterb c.ltransport_ratio1 i.land_irig_bi  i.landown_yn c.edu_level  c.family_size c.lDEM_mean c.lrootwater_mean c.lROUGH_mean i.soil_qauality i.prod_type2    
global xlistnc   c.lfamily_labor_cost_share c.ldist_waterb c.ltransport_ratio1 i.land_irig_bi  i.landown_yn c.edu_level  c.family_size c.lDEM_mean c.lrootwater_mean c.lROUGH_mean i.soil_qauality i.prod_type2 i.rabi_karif1    

global xlist_costpa c.yieldpa_comb c.input_costpa_odlabor  c.distance_waterb c.transport_ratio1 i.land_irig_bi   i.landown_yn c.edu_level c.family_size c.DEM_mean c.rootwater_mean c.ROUGH_mean i.soil_qauality i.prod_type2

global xlist2 c.ldist_waterb c.ltransport_ratio1 i.land_irig_bi i.soil_qauality i.prod_type2 i.landown_yn  c.edu_level c.family_size  c.lDEM_mean  c.lrootwater_mean c.lslopepe_2##c.lslopepe_2 c.ROUGH_mean

set more off

//gen lfam_self_worker = ln(fam_self_worker+1)

reg lprod_comb  c.llabor_cost_total_comb c.linput_cost_odlabor lfam_self_worker c.lland_culti 

reg lprod_comb  c.lfam_self_worker  c.lland_culti
predict loutput_pred,xb
gen output_pred= exp(loutput_pred)
gen prod_comb_pred=exp(lprod_comb_pred)

drop mpl
gen mpl=0.05536*(output_pred/fam_self_worker) //lprod_comb_pred is a predicted value
gen imput_cost=mpl*fam_self_worker //mpl_rs is the marginal prod of family labor
//drop input_cost_comb_imput


egen input_cost_combr=rsum(input_cost_total_comb land_rent_cost )
gen input_cost_combr_pa=input_cost_combr/land_culti_total
gen linput_costpa_combr=ln(input_cost_combr_pa)

egen input_cost_comb_imput=rsum(input_total imput_cost s10c1_195 s10c2_195)
egen input_cost_combr_imput=rsum(input_total imput_cost s10c1_195 s10c2_195 land_rent_cost)
gen input_cost_combr_imput_pa=input_cost_combr_imput/land_culti_total
gen linput_cost_combr_imput_pa=ln(input_cost_combr_imput_pa)

gen io_ratio_total_combr_imput=prod_comb/(input_cost_combr_imput)
gen lio_ratio_total_combr_imput=ln(io_ratio_total_combr_imput)
gen io_ratio_comb_imput3=prod_comb3/input_cost_comb_imput
gen lio_ratio_comb_imput3=ln(io_ratio_comb_imput3)

gen linput_cost_comb_imput = ln(input_cost_comb_imput)
gen input_cost_comb_imput_pa =input_cost_comb_imput/land_culti_total
gen linput_cost_comb_imput_pa=ln(input_cost_comb_imput_pa)
gen io_ratio_comb_imput= yieldpa_comb/input_cost_comb_imput_pa
gen lio_ratio_comb_imput = ln(io_ratio_comb_imput)

//PFP models on MPL basis
asdoc svy:reg c.lyieldpa_comb  c.lland_culti  , replace nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_comb_imput_pa c.lfamily_labor_cost_share, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
//asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_comb_imput_pa  $xlist0,  nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No) 
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_comb_imput_pa  $xlistsq, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No) 
//asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_comb_imput_pa  $xlist,   nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes) 
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_comb_imput_pa  $xlistnc, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes) 
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share c.linput_cost_comb_imput_pa  $xlistnc, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_I)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes) 
asdoc svy:reg c.lyieldpa_comb3 c.lland_culti c.linput_cost_comb_imput_pa  $xlistnc, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS-PAI)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes) 
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_cost_combr_imput_pa $xlistnc, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_IR)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes) 
//psacalc beta lland_culti, delta(1)

asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb    ,  nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No) 
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb c.lfamily_labor_cost_share ,  nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No) 
//asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb $xlist0,  nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No)
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb $xlistsq, nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No)
//asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb $xlist,   nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_total_comb $xlistnc, nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share c.linput_costpa_total_comb $xlistnc, nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)
asdoc svy:reg c.lyieldpa_comb3 c.lland_culti c.linput_costpa_total_comb $xlistnc, nest save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS-PAM) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)
asdoc svy:reg c.lyieldpa_comb  c.lland_culti c.linput_costpa_combr      $xlistnc, nest  save(Result1) title(Table 1. PFP Yield per acre Models on MPL and Market basis) fs(11) cnames(OLS_MR) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)


asdoc, text(\par) save(Result1)
//TFP models Market wage basis
asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti , nest reset save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti c.lfamily_labor_cost_share , nest save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
//asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti $xlist0,  nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, Yes, Geo & Soil Controls, No, Crop Choice , No)  
asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti $xlistsq, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No)  
//asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti $xlist,   nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_comb_imput         c.lland_culti c.lland_culti#c.lfamily_labor_cost_share $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_I) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_comb_imput3        c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS-IPA)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)   
asdoc svy:regress  lio_ratio_total_combr_imput  c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS-IR)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  


asdoc svy:regress  lio_ratio_total_comb     c.lland_culti , nest save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
asdoc svy:regress  lio_ratio_total_comb     c.lland_culti c.lfamily_labor_cost_share, nest save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, No, Geo & Soil Controls, No, Crop Choice , No)  
//asdoc svy:regress  lio_ratio_total_comb     c.lland_culti $xlist0,  nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, No, Crop Choice , No)  
asdoc svy:regress  lio_ratio_total_comb     c.lland_culti $xlistsq, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , No)  
//asdoc svy:regress  lio_ratio_total_comb     c.lland_culti $xlist,   nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_total_comb     c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_total_comb     c.lland_culti c.lland_culti#c.lfamily_labor_cost_share $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS_M) add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  
asdoc svy:regress  lio_ratio_total_comb3    c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS-MPA)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)   
asdoc svy:regress  lio_ratio_total_combr    c.lland_culti $xlistnc, nest  save(Result1) title(Table 3. TFP Models MPL and Market wage basis) fs(11) cnames(OLS-MR)  add(Farm & HH Controls, Yes, Geo & Soil Controls, Yes, Crop Choice , Yes)  


//margins plot of interaction term
asdoc, text(\par) save(Result1)
svy:reg c.lyieldpa_comb  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share c.linput_cost_comb_imput_pa  $xlistnc 
margins, at(lland_culti=(-3 6) lfamily_labor_cost_share=(0 5)) plot
graph save Graph "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_imput.gph",replace
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_imput.tif", as(tif) replace

svy:reg c.lyieldpa_comb  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share c.linput_costpa_total_comb  $xlistnc 
margins, at(lland_culti=(-3 6) lfamily_labor_cost_share=(0 5)) plot
graph save Graph "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_market.gph", replace
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_market.tif", as(tif) replace

graph combine "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_imput.gph" "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\yield_market.gph", iscale(*1.) xsize(11.2) ysize(5) graphregion(margin(zero)) plotregion(margin(zero))
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\combine_yield.tif", as(tif) replace



//margins plot of interaction term
svy:reg lio_ratio_comb_imput  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share  $xlistnc 
margins, at(lland_culti=(-3 6) lfamily_labor_cost_share=(0 5)) plot
graph save Graph "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_imput.gph", replace
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_imput.tif", as(tif) replace

svy:reg lio_ratio_total_comb  c.lland_culti c.lland_culti#c.lfamily_labor_cost_share  $xlistnc 
margins, at(lland_culti=(-3 6) lfamily_labor_cost_share=(0 5)) plot
graph save Graph "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_market.gph", replace
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_market.tif", as(tif) replace

graph combine "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_imput.gph" "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\TFP_market.gph", iscale(*1.) xsize(11.2) ysize(5) graphregion(margin(zero)) plotregion(margin(zero))
graph export "E:\Essays on Agriculture land inequality\Thesis\farm size and prductivity\Paper Write-up\1 farm size & productivity\4 Economic development and cultural change\reviewvers decision\combine_TFP.tif", as(tif) replace




asdoc, text(\par) save(Result1)
//SFA Models
//MPL basis
asdoc frontier lyieldpa_comb c.linput_cost_comb_imput_pa  $xlist2 , uhet (  i.farmsizesl i.family_worker_yn) iterate( 200) nest reset save(Result1) title(Table 7. SFA Models) fs(11) cnames(YPAI) add(Controls, Yes) 
asdoc frontier lyieldpa_comb3 c.linput_cost_comb_imput_pa $xlist2 , uhet ( i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(YPA-PAI) add(Controls, Yes) 
asdoc frontier lio_ratio_comb_imput   $xlist2, uhet (  i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(TFPI) add(Controls, Yes) 
asdoc frontier lio_ratio_comb_imput3  $xlist2, uhet ( i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(TFP-PAI) add(Controls, Yes) 

//Market wage rate

asdoc frontier lyieldpa_comb c.linput_costpa_total_comb $xlist2 , uhet (  i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(YPAM) add(Controls, Yes) 
asdoc frontier lyieldpa_comb3 c.linput_costpa_total_comb $xlist2 , uhet (  i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(YPA-PAM) add(Controls, Yes) 
asdoc frontier lio_ratio_total_comb   $xlist2, uhet (  i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(TFPM) add(Controls, Yes) 
asdoc frontier lio_ratio_total_comb3  $xlist2, uhet (i.farmsizesl i.family_worker_yn) iterate( 200) nest save(Result1) title(Table 7. SFA Models) fs(11) cnames(TFP-PAM) add(Controls, Yes) 




asdoc, text(\par) save(Result1)
//TESTING FOR LABOUR MARKET IMPERFECTIONS
 asdoc reg lprod_comb i.farm_size_dummy#c.llabor_cost_total_comb c.linput_cost_odlabor, nest reset save(Result1) title(Table 8. Testing Labor Market Imperferctions and farm family labor productivity Models) fs(11) cnames(OLS-MPL) add(Controls, Yes)

//variable of interest is share of family labor cost in total labor cost
asdoc reg lprod_comb c.linput_cost_total_comb c.lland_culti c.lfamily_labor_cost_share , nest save(Result1) title(Table 8. Testing Labor Market Imperferctions and farm family labor productivity Models) fs(11) cnames(OLS-LCS) add(Controls, Yes)
//margins, at(lfamily_labor_cost_share=(0(0.4)4.6) lfamily_labor_cost_share=(0(0.4)4.6)) atmeans plot
asdoc reg lprod_comb c.linput_cost_total_comb c.lland_culti c.family_labor_cost_share , nest save(Result1) title(Table 8. Testing Labor Market Imperferctions and farm family labor productivity Models) fs(11) cnames(OLS-CS) add(Controls, Yes)
//margins, at(family_labor_cost_share=(0(5)100) family_labor_cost_share=(0(5)100)) atmeans plot

//variable of interest is number of family worker over farm size
asdoc reg lprod_comb c.linput_cost_total_comb  c.lfamily_worker_mean#i.farm_size_dummy , nest save(Result1) title(Table 8. Testing Labor Market Imperferctions and farm family labor productivity Models) fs(11) cnames(OLS-LFW-No) add(Controls, Yes)

//varaible of interest is number of family worker per acre
asdoc reg lprod_comb c.linput_cost_total_comb c.lland_culti c.lfamily_worker_pa , nest save(Result1) title(Table 8. Testing Labor Market Imperferctions and farm family labor productivity Models) fs(11) cnames(OLS-LFW-PA) add(Controls, Yes)
//margins, at(lfamily_worker_pa=(0(0.2)2.8) lfamily_worker_pa=(0(0.2)2.8)) atmeans plot


asdoc, text(\par) save(Result1)
// yield per acre over crops types
asdoc reg yieldpa i.prod_type2 input_costpa_total, reset save(Result1) title(Table 9. Per acre yield by crops types) fs(11) cnames(OLS-YPA) add(Controls, Yes)

//labor intensity per acre by size
asdoc reg labor_costpa_total_comb land_culti_total $xlist_costpa, reset save(Result1) title(Table 10. Labor intensity across farm size) fs(11) cnames(OLS-Labor-PA) add(Controls, Yes)

asdoc, text(\par) save(Result1)
//summary statisticsr
asdoc sum yieldpa_comb yieldpa_comb3 io_ratio_total_comb io_ratio_total_comb3 io_ratio_comb_imput land_culti_total family_worker_pa transport_ratio land_irig_bi agri_live_bi soil_qauality prod_type2 landown_yn edu_level DEM_mean rootwater_mean ROUGH_mean distance_waterb, save(Result1)

//testing for return to scale
asdoc reg lprod_comb c.linput_cost_total_comb c.lland_rent_cost
asdoc test (_b[lland_rent_cost] +  _b[linput_cost_total_comb]=1)

asdoc reg lprod_comb c.linput_cost_comb_imput  c.lland_rent_cost
asdoc test (_b[lland_rent_cost] +  _b[linput_cost_comb_imput]=1)


//testing for return to scale
asdoc reg lprod_comb3 c.linput_cost_total_comb c.lland_rent_cost
asdoc test (_b[lland_rent_cost] +  _b[linput_cost_total_comb]=1)

asdoc reg lprod_comb3 c.linput_cost_comb_imput  c.lland_rent_cost
asdoc test (_b[lland_rent_cost] +  _b[linput_cost_comb_imput]=1)
